package me.magicall.db.sql.mysql;

import me.magicall.db.sql.SqlElementTemplate;

/**
 * limit语句,似乎是mysql的特性
 * 
 * @author MaGiCalL
 */
public class MysqlLimit extends SqlElementTemplate {

	private int offset;
	private int size;

	public MysqlLimit() {
		super();
	}

	public MysqlLimit(final int size) {
		super();
		this.size = size;
	}

	public MysqlLimit(final int offset, final int size) {
		super();
		this.offset = offset;
		this.size = size;
	}

	@Override
	public StringBuilder appendTo(final StringBuilder sb) {
		sb.append(" LIMIT ");
		final int offset = getOffset();
		if (offset != 0) {
			sb.append(offset).append(",");
		}
		return sb.append(getSize()).append(" ");
	}

	public int getOffset() {
		return offset;
	}

	public void setOffset(final int offset) {
		this.offset = offset;
	}

	public int getSize() {
		return size;
	}

	public void setSize(final int size) {
		this.size = size;
	}
}
